{extend name="layout" /}
{block name="content"}
<div class="mui-content">
	<!--block-->
	<div class="uk-clearfix uk-margin-small-top">
		<div class="main-input-group">
			<form id="formid" method="post">
			<div class="mui-table-view mui-in-zero uk-text-xsmall">
				<div class="mui-table-view-cell">
					<div class="tm-flex flex-align-center">
						<div class="tm-5em tm-flex-head">
							收货人
						</div>
						<div class="tm-flex-1">
							<input class="tm-input" type="text" value="{$info.consignee}" name="consignee" placeholder="请填写收货人" style="text-align: right;" />
						</div>
					</div>
				</div>
				<div class="mui-table-view-cell">
					<div class="tm-flex flex-align-center">
						<div class="tm-5em tm-flex-head">
							联系电话
						</div>
						<div class="tm-flex-1">
							<input class="tm-input" type="text" value="{$info.phone}" name="phone" placeholder="请填写联系电话" style="text-align: right;" />
						</div>
					</div>
				</div>
				<div class="mui-table-view-cell">
					<div class="mui-navigate-right">
						<div class="tm-cell-pad">
							<div class="tm-flex flex-align-center">
								<div class="tm-5em tm-flex-head">
									所在地区
								</div>
								<div class="tm-flex-1">
									<input id='city-picker' class="tm-input uk-text-right" type="text" value="{$info.city}" name="city" placeholder="请选择" readonly style="float: right;" />
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="mui-table-view-cell">
					<div class="">
						<div class="tm-input-body">
							<textarea class="addres-textarea" rows="3" name="address" id="address" placeholder="请输入详细地址，不少于5个字">{$info.address}</textarea>
						</div>
					</div>
				</div>
			</div>
			<input type="hidden" name="id" value="{$info.id}">
			</form>
		</div>
	</div>
	<!--/block-->
</div>
{/block}
{block name="script"}
<script src="{$js_path}jquery-weui.min.js"></script>
<script src="{$js_path}components/sticky.min.js"></script>
<script src="{$js_path}swiper.min.js"></script>
<script src="{$js_path}city-picker.min.js" charset="utf-8"></script>
<script src="{$js_path}main.js"></script>
<script>
	$("#city-picker").cityPicker({
		title: "选择所在地区",
		onChange: function(picker, values, displayValues) {
			console.log(values, displayValues);
		}
	});
</script>
<script type="text/javascript">
    $(function(){
        c3_navtive_user.right_button_item1 = {
            title:"保存",
            callback:function(){
                var content = new Array();
                content['title'] = "提示";
                content['message'] = "确定要保存吗？";
                c3_navtive_user.doActionAnsy('open_confirm_dialog',content,function(){
                	var city = $("#city-picker").val();
                	var address = $("#address").val();
                	if (!city) {
                		coco_msg('请选择所在地区');
                		return false;
                	}
                	if (!address) {
                		coco_msg('请填写详细的地址');
                		return false;
            		}
                    datajson = $("#formid").serialize();
                    $.ajax({
				    	url: "{:url('v1/adminuser/update_address')}",
				    	type:'post',
				    	dataType: 'json',
				    	data: datajson,
				    	beforeSend: function(request) {
				    		request.setRequestHeader("token", token);
				    		request.setRequestHeader("timestamp", timestamp);
				    	},
				    	error: function (XMLHttpRequest, textStatus, errorThrown) {
				    		coco_close_loading();
				    		var codetext = XMLHttpRequest.responseText;
				    		codejson = eval("(" + codetext + ")");
				    		coco_msg(codejson.msg);
				    		return false;
				    	},
				    	success:function(datajson){
				    		coco_msg('修改成功');
				    		setTimeout(function() {coco_close_window()}, 100);
				    	}
				    })
                });
            }
        };
        var button_item = [
            {
                title: "保存",
                returnTag:'1'
            }
        ];
        {if !isset($isphone)}
            c3_navtive_user.doActionFunc("configMenu",button_item,function(datas){
                returntag = eval('(' + datas + ')');
                if(returntag.returnTag == 1){
                    var content = new Array();
                    content['title'] = "提示";
                    content['message'] = "确定要保存吗？";
                    c3_navtive_user.doActionAnsy('open_confirm_dialog',content,function(){
                    	var city = $("#city-picker").val();
	                	var address = $("#address").val();
	                	if (!city) {
	                		coco_msg('请选择所在地区');
	                		return false;
	                	}
	                	if (!address) {
	                		coco_msg('请填写详细的地址');
	                		return false;
                		}
                        datajson = $("#formid").serialize();
                        $.ajax({
					    	url: "{:url('v1/adminuser/update_address')}",
					    	type:'post',
					    	dataType: 'json',
					    	data: datajson,
					    	beforeSend: function(request) {
					    		request.setRequestHeader("token", token);
					    		request.setRequestHeader("timestamp", timestamp);
					    	},
					    	error: function (XMLHttpRequest, textStatus, errorThrown) {
					    		coco_close_loading();
					    		var codetext = XMLHttpRequest.responseText;
					    		codejson = eval("(" + codetext + ")");
					    		coco_msg(codejson.msg);
					    		return false;
					    	},
					    	success:function(datajson){
					    		coco_msg('修改成功');
					    		setTimeout(function() {coco_close_window()}, 100);
					    	}
					    })
                    });
                }
                else if(returntag.returnTag == 2){
                    c3_navtive_user.doActionAnsy('openSearch',null,function(){});
                }
            });
        {/if}
    })
</script>
{/block}